<?php

namespace WebExpres\ContentBundle\Repository;

use Doctrine\ORM\EntityRepository;

class SeccionRelationRepository extends EntityRepository
{
 
     public function findSeccionsMaxPosition($Seccio, $idhotel) {
        
        return $this->getEntityManager()
            ->createQuery('SELECT sr FROM WebExpres\ContentBundle\Entity\SeccionRelation sr WHERE sr.idsecfill = :seccio and sr.idhotel = :idhotel ORDER BY sr.idseccion DESC')
            ->setParameter('seccio', $Seccio)
            ->setParameter('idhotel', $idhotel)
            ->getResult();
        
    }
    
    public function findSeccionsByIdhotel($idhotel) {
        
        return $this->getEntityManager()
            ->createQuery('SELECT sr FROM WebExpres\ContentBundle\Entity\SeccionRelation sr WHERE sr.idhotel = :idhotel ORDER BY sr.idsecfill, sr.position ASC')
            ->setParameter('idhotel', $idhotel)
            ->getResult();
        
    }
    
    
    public function findSeccionsByIdsecfill($Seccion) {
        
        return $this->getEntityManager()
            ->createQuery('SELECT sr FROM WebExpres\ContentBundle\Entity\SeccionRelation sr WHERE sr.idsecfil = :seccion ORDER BY sr.position ASC')
            ->setParameter('seccion', $Seccion)
            ->getResult();
        
    }
   
}